import 'package:namewava/jc_tabbar.dart';
import 'package:namewava/utils/jc_global.dart';
import 'package:url_launcher/url_launcher.dart';

class JcPrivacyProtocol {
  ///0用户协议 1隐私
  static launchPrivacyProtocol(int type) {
    if (type == 1) {
      JcGlobal.of(navigatorKey.currentContext!).logReport({'page': 'privacy'});
      String jcPrivacyPolicy =
          'https://h5.cosmofusionly.xyz/privacyPolicy.html';
      _launchInBrowser(jcPrivacyPolicy);
    } else {
      JcGlobal.of(navigatorKey.currentContext!).logReport({'page': 'terms'});
      String jcProtocol = 'https://h5.cosmofusionly.xyz/termConditions.html';
      _launchInBrowser(jcProtocol);
    }
  }

  static _launchInBrowser(String url) async {
    if (!await launchUrl(
      Uri.parse(url),
      mode: LaunchMode.inAppBrowserView,
    )) {
      throw Exception('Could not launch $url');
    }
  }
}
